#include <iostream>
#include <vector>
#include <queue>

using namespace std;

// #define MAX_N 100000
// int masks[MAX_N + 5];

int main()
{
    priority_queue<int, vector<int>, greater<int>> heap;
    int n, k;
    cin >> n >> k;
    for(int i = 0, a; i < n; i++)
    {
        cin >> a;
        heap.push(a);
    }
    int days = 0;
    while(k >= 0)
    {
        days += 1;
        int top = heap.top();
        heap.pop();
        k -= top;
        heap.push(top * 2);
    }
    cout << days - 1;
    return 0;
}